Page({
  data: {
    paymentList: [
      { date: '2024-07-01', description: '房租', amount: 3000 },
      { date: '2024-07-04', description: '信用卡还款', amount: 2000 },
      { date: '2024-07-05', description: '水电费', amount: 500 },
      { date: '2024-08-06', description: '借贷', amount: 5000 },
      { date: '2024-07-08', description: '购物', amount: 1500 },
      { date: '2024-07-10', description: '网费', amount: 100 },
      { date: '2024-07-14', description: '手机话费', amount: 200 },
      { date: '2024-07-15', description: '健身房会员费', amount: 800 },
      { date: '2024-07-16', description: '医疗费用', amount: 1200 },
      { date: '2024-07-17', description: '书籍购买', amount: 300 },
      { date: '2024-07-18', description: '交通费', amount: 400 },
      { date: '2024-07-18', description: '外卖', amount: 300 },
      { date: '2024-07-19', description: '电影票', amount: 150 },
      { date: '2024-07-22', description: '咖啡', amount: 100 },
      { date: '2024-07-23', description: '理发', amount: 200 },
      { date: '2024-07-24', description: '麦当劳', amount: 30 },
      { date: '2024-07-25', description: '肯德基', amount: 50 },
      { date: '2024-07-26', description: '购物', amount: 200 },
      { date: '2024-07-27', description: '外卖', amount: 30 },
      { date: '2024-07-28', description: '健身', amount: 680 },
      { date: '2024-07-29', description: '游泳', amount: 30 },
      { date: '2024-07-30', description: '手机', amount: 6800 },
      { date: '2024-07-31', description: '书籍', amount: 100 },
      { date: '2024-08-01', description: '电脑', amount: 20000 },
      { date: '2024-08-02', description: '机车', amount: 60000 },
      { date: '2024-08-03', description: '保险费', amount: 2000 },
      { date: '2024-08-04', description: '汽车保养', amount: 2000 },
      { date: '2024-08-05', description: '家具用品', amount: 3000 },
      { date: '2024-08-06', description: '旅游门票', amount: 199 },
      { date: '2024-08-07', description: '话费充值', amount: 200 },
      { date: '2024-08-08', description: '电影票', amount: 180 },
      { date: '2024-08-09', description: '宽带费', amount: 500 },
      { date: '2024-08-10', description: '零食', amount: 100 },
      { date: '2024-08-11', description: '礼物', amount: 200 },
      { date: '2024-08-12', description: '打车费', amount: 50 },
      { date: '2024-08-13', description: '水费', amount: 200 },
      { date: '2024-08-14', description: '电费', amount: 200 },
      { date: '2024-08-15', description: '维修费', amount: 100 },
      { date: '2024-08-16', description: '快递费', amount: 20 },
      { date: '2024-08-17', description: '软件订阅', amount: 200 },
      { date: '2024-08-18', description: '书籍订阅', amount: 200 },
      { date: '2024-08-19', description: '腾讯视频订阅', amount: 200 },
      { date: '2024-08-20', description: '太阳眼镜', amount: 50 },
      { date: '2024-08-21', description: '鼠标', amount: 398 },
      { date: '2024-08-22', description: '键盘', amount: 400 },
      { date: '2024-08-23', description: '学费', amount: 10000 },
      { date: '2024-08-24', description: '游戏充值', amount: 4000 },
      { date: '2024-07-25', description: '电视', amount: 2000 },
      { date: '2024-07-26', description: '床垫', amount: 1000 },
    ]
  },
  onLoad: function() {
    this.filterPaymentsByMonth();
  },
  filterPaymentsByMonth: function() {
    const now = new Date();
    const currentYear = now.getFullYear();
    const currentMonth = now.getMonth() + 1; // getMonth() 返回的月份是从0开始的
    const filteredPayments = this.data.paymentList.filter(payment => {
      const paymentDate = new Date(payment.date);
      return paymentDate.getFullYear() === currentYear && paymentDate.getMonth() + 1 === currentMonth;
    });
    this.setData({
      paymentList: filteredPayments
    });
  }
});
